package com.xiaoke.domain.dtos;


import javax.validation.constraints.*;
import java.util.Objects;

/**
 * @Author xiaoke
 * @Description 使用Validation注解
 * @Date 2023/7/23 23:58
 */
public class Demo2Dto {
    @NotBlank(message = "用户名不能为空")
    @Size(min = 4,message = "用户不能小于4位")
    @Size(max = 12,message = "用户不能大于16位")
    private String username;
    @NotBlank(message = "密码不能为空")
    private String password;
    @NotNull(message = "年龄不能位空")
    private Integer age;

    public Demo2Dto() {
    }

    public Demo2Dto(String username, String password, Integer age) {
        this.username = username;
        this.password = password;
        this.age = age;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Demo2Dto demo2Dto = (Demo2Dto) o;
        return Objects.equals(username, demo2Dto.username) && Objects.equals(password, demo2Dto.password) && Objects.equals(age, demo2Dto.age);
    }

    @Override
    public int hashCode() {
        return Objects.hash(username, password, age);
    }
}
